import numpy as np
import stl
from stl import mesh
import os

file_stl = ['21',
            '22',
            '23']
file_output = 'mesh.stl'

mesh_stl = []
t_data = []
for k in range(len(file_stl)):
    mesh_stl.append(mesh.Mesh.from_file(file_stl[k] + ".stl"))
    mesh_stl[k].name = file_stl[k]
    # t_data = t_data + [copy.data for copy in mesh_stl[k]]

# combined = mesh.Mesh(np.concatenate(t_data))
os.system("mkdir temp")
os.chdir("./temp")

str_file = ""
for k in range(len(file_stl)):
    mesh_stl[k].save(file_stl[k] + ".stl", mode=stl.Mode.ASCII)
    with open(file_stl[k] + ".stl") as f:
        str_file = str_file + f.read()

os.chdir("..")
os.system("rm -rf ./temp")

stream_file = open(file_output, "w")
print(str_file, file=stream_file)
stream_file.close()
